//假设每一天都要卖出，那么最大值就是当天的价钱减去之前价钱的最小值
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int minPrice = prices[0];
        int ret = 0;
        for (int i = 1; i < prices.size(); i++)
        {
            ret = max(ret, prices[i] - minPrice);
            minPrice = min(minPrice, prices[i]);
        }

        return ret;
    }
};